<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
<title>Insert title here</title>
<script src="${pageContext.request.contextPath }/js/commonSearch.js" type="text/javascript"></script>
</head>
<body>
<form name="frmEditOrDelete" action="${pageContext.request.contextPath}/book">
	<input type="hidden" name="id">
	<input type="hidden" name="flag">
</form>
	<form name="frmSearch" action="${pageContext.request.contextPath }/book">
	<table class="table">
		<tr>
			<th colspan="6">图书信息查询</th>
		</tr>
		<tr>
			
			<th colspan="4">
				<input type="hidden" name="pageNo" value="1">
				<input type="hidden" name="flag" value="search">
				<input type="text" placeholder="请输入要查询的图书名" class="form-control"	name="bookName">
			</th>
			<th>
				<input type="submit" class="btn btn-secondary" value="查询">
			</th>
			<th>
				<c:if test="${curUser.type==1 }">
				<input type="button" class="btn btn-secondary" value="添加图书" onclick="goAdd('${pageContext.request.contextPath}/book')">
				</c:if>
				
				
			</th>
		</tr>
		<tr>
			<th colspan="6">${msg }	</th>
		</tr>
		<c:if test="${not empty page }">
		<c:if test="${page.totalCount == 0 }">
		<tr>
			<th colspan="7">查询无结果	</th>
		</tr>
		
		</c:if>
		<c:if test="${page.totalCount != 0 }">
		
	<tr>
		<th>序号</th>
		<th>图书名</th>
		<th>ISBN</th>
		<th>作者</th>
		<th>出版日期</th>
		<th>库存数量</th>		
		<th>操作</th>
	</tr>
	
	<c:forEach var="b" items="${page.records }">
	
		<tr>
			<td>${b.id}</td>
			<td>${b.bookName}</td>
			<td>${b.isbn}</td>
			<td>${b.author}</td>
			<td>${b.pubTime}</td>
			<td>${b.count}</td>
			<td>
				<c:if test="${curUser.type==1 }">
				
					<input type="button" value="修改" class="btn btn-info" onclick="goEdit('${b.id}')">
					&nbsp;
					<input type="button" value="删除" class="btn btn-warning" onclick="goDelete('图书','${b.id}')">
				</c:if>
				<c:if test="${curUser.type==0 }">
				
					<input type="button" value="借阅" class="btn btn-info" onclick="goBorrow('${b.id}')">
				</c:if>
			</td>
		</tr>
		
	</c:forEach>
		<tr>
			<td colspan="6">
				<div class="container mt-3">				  
				  <ul class="pagination justify-content-center">
				  <li class="page-item"><a class="page-link" href="javascript:goSearch(1);">首页</a></li>
							    <li class="page-item"><a class="page-link" href="javascript:goPre();">上一页</a></li>
							    <li class="page-item"><a class="page-link" href="javascript:void(0);">当前第[${ page.pageNo}]页，共[${page.pageMax }]页，共[${page.totalCount }]条记录</a></li>
							    
							    <li class="page-item"><a class="page-link" href="javascript:goNext(${page.pageMax });">下一页</a></li>
							    <li class="page-item"><a class="page-link" href="javascript:goSearch(${page.pageMax });">尾页</a></li>
				  </ul>
				 
				</div>
			</td>
		</tr>
	</table>
	
	</form>

</c:if>
</c:if>
</body>
</html>